use strict;


=head1 NAME

  RTx::AssetTracker::Users -- Class Description
 
=head1 SYNOPSIS

  use RTx::AssetTracker::Users

=head1 DESCRIPTION


=head1 METHODS

=cut

package RTx::AssetTracker::Users;

use vars qw( @ISA );
@ISA= qw(RT::Users);

sub WhoHaveRight {
    my $self = shift;
    my %args = ( Right                  => undef,
                 Object                 => undef,
                 IncludeSystemRights    => undef,
                 IncludeSuperusers      => undef,
                 IncludeSubgroupMembers => 1,
                 @_ );

    if (defined $args{'ObjectType'} || defined $args{'ObjectId'}) {
        $RT::Logger->crit("$self WhoHaveRight called with the Obsolete ObjectId/ObjectType API");
        return(undef);
    }
        my @privgroups;
        my $Groups = RTx::AssetTracker::Groups->new($RT::SystemUser);
        $Groups->WithATRight(Right=> $args{'Right'},
                     Object => $args{'Object'},
                     IncludeSystemRights => $args{'IncludeSystemRights'},
                     IncludeSuperusers => $args{'IncludeSuperusers'});
        while (my $Group = $Groups->Next()) {
                push @privgroups, $Group->Id();
        }


    if (@privgroups) {
        $self->WhoBelongToGroups(Groups => \@privgroups,
                                 IncludeSubgroupMembers => $args{'IncludeSubgroupMembers'});
    }
    else {
        # We don't have any group that matches -- make it impossible.
        $self->Limit( FIELD => 'Id', VALUE => 'IS', OPERATOR => 'NULL' );
    }
}


1;
